import * as global_way from './lib/ways/global.js'
import * as filters from './lib/ways/filter.js'
// import "./lib/rem/rem.js";
// 注册全局组件
// const context = require.context('@/components/gg/global', true, /\.vue$/)
// context.keys().forEach(v => {
//     let item = v.replace('./', '').replace('.vue', '')
//     let component = context(v).default
//     Vue.component('gg-' + item, component)
// })
const path = require('path')
// console.log(, "path");
import directives from './lib/directives/index.js'
const context = require.context('./lib/components', true, /\.vue$/)
// const context = require.context("@/components/global", true, /\.vue$/);
console.log(context.keys(), 'context')
const componentsArr = []
// const componentsArr = [box, btn, foot, hint, iconTitle, isShow, row1, scrollTab, selectTag, select, tag];
// 这里要导出一个包含 install 方法的对象
const plugin = {
    // 这里要导出一个 install 方法
    install(Vue, options) {
        if (options && options.components) {
            let components = options.components
            components.forEach(v => {
                let arr = context.keys()
                let contextFilter = arr.filter(component => context(component).default.name === v)
                console.log(contextFilter, 'contextFilter')
                contextFilter.forEach(v => {
                    let component = context(v).default
                    Vue.component(component.name, component)
                })
            })
        } else {
            context.keys().forEach(v => {
                let item = v.replace('./', '').replace('.vue', '')
                let component = context(v).default
                Vue.component(component.name, component)
            })
        }
        Vue.use(directives, options)
        Object.keys(global_way).forEach(key => {
            let a = '$' + key
            Vue.prototype[a] = global_way[key]
        })
        Object.keys(filters).forEach(key => {
            Vue.filter(key, filters[key])
        })
    }
}
export default plugin
